home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-29 | 4.5 KB | 187 lines | [TEXT/MPS ] |
- {$S Main}
-
- (* ------------------------------------------------- *)
- (* MAIN PROGRAM *)
- (* ------------------------------------------------- *)
- (* Purpose: Perform the routine initializations and *)
- (* enter the event loop. *)
- (* ------------------------------------------------- *)
-
- PROGRAM example;
-
- USES
- MemTypes,QuickDraw,OSIntf,ToolIntf,PackIntf,
- Dispatcher;
-
- VAR
- myEvent : EventRecord;
- doneFlag : boolean;
- code : integer;
- whichWindow : WindowPtr;
- tempRect,OldRect : Rect;
- mResult : longint;
- theMenu, theItem : integer;
- chCode : integer;
- ch : char;
- myPt : Point;
-
- BEGIN
- MoreMasters;
- MoreMasters;
- MoreMasters;
- MoreMasters;
- InitGraf(@thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(nil);
- FlushEvents ( everyEvent , 0 );
- InitCursor;
-
- ClearMenuBar;
- SetMenuBar(GetNewMBar (MBarID));
- AddResMenu(GetMHandle (AppleID), 'DRVR');
- DrawMenuBar;
-
- doneFlag := FALSE;
-
- REPEAT
- SystemTask;
-
- IF GetNextEvent(everyEvent, myEvent) THEN
- BEGIN
- code := FindWindow(myEvent.where, whichWindow);
-
- CASE myEvent.what OF
- MouseDown :
- BEGIN
- IF (code = inMenuBar) then
- BEGIN
- mResult := MenuSelect(myEvent.Where);
- theMenu := HiWord(mResult);
- theItem := LoWord(mResult);
- Handle_My_Menu(doneFlag, theMenu, theItem);
- END;
-
- IF (code = InDrag) then
- BEGIN
- tempRect := screenbits.bounds;
- SetRect(tempRect,tempRect.Left+10,tempRect.Top+25,tempRect.Right-10,tempRect.Bottom - 10);
- DragWindow(whichWindow, myEvent.where, tempRect);
- END;
-
- IF ((code = inGrow) and (whichWindow <> nil)) then
- BEGIN
- SetPort(whichWindow);
-
- myPt := myEvent.where;
- GlobalToLocal(myPt);
-
- OldRect := WhichWindow^.portRect;
-
- WITH screenbits.bounds DO
- SetRect( tempRect, 15, 15,
- (right - left), (bottom - top) - 20);
- mResult := GrowWindow(whichWindow,myEvent.where, tempRect);
- SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE);
- SetPort(whichWindow);
- SetRect(tempRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15);
- EraseRect(tempRect);
- InvalRect(tempRect);
- SetRect(tempRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15);
- EraseRect(tempRect);
- InvalRect(tempRect);
- DrawGrowIcon(whichWindow);
- END;
-
- IF (code = inZoomIn) or (code = inZoomOut) then
- BEGIN
- IF (WhichWindow <> nil) then
- BEGIN
- SetPort(whichWindow);
- myPt := myEvent.where;
- GlobalToLocal(myPt);
- OldRect := whichWindow^.portRect;
- IF TrackBox(whichWindow, myPt, code) then
- BEGIN
- ZoomWindow(WhichWindow, code, TRUE);
- SetRect(tempRect, 0, 0, 32000, 32000);
- EraseRect(tempRect);
- InvalRect(tempRect);
- END;
- END;
- END;
-
- IF (code = inGoAway) then
- BEGIN
- If TrackGoAway(whichWindow,myEvent.where) then
- BEGIN
- END;
- END;
-
- IF (code = inContent) then
- BEGIN
- IF (whichWindow <> FrontWindow) then
- SelectWindow(whichWindow)
- else
- BEGIN
- SetPort(whichWindow);
- END;
- END;
-
- IF (code = inSysWindow) then
- SystemClick(myEvent, whichWindow);
-
- END;
-
- KeyDown,AutoKey:
- BEGIN
- with myevent do
- BEGIN
- chCode := BitAnd(message, CharCodeMask);
- ch := CHR(chCode);
- IF (Odd(modIFiers div CmdKey)) then
- BEGIN
- mResult := MenuKey(ch);
- theMenu := HiWord(mResult);
- theItem := LoWord(mResult);
- IF (theMenu <> 0) then
- Handle_My_Menu(doneFlag, theMenu, theItem);
- END
- END;
- END;
-
- UpDateEvt :
- BEGIN
- whichWindow := WindowPtr(myEvent.message);
- BeginUpdate(whichWindow);
- EndUpdate(whichWindow);
- END;
-
- DiskEvt :
- BEGIN
- IF (HiWord(myevent.message) <> noErr) then
- BEGIN
- myEvent.where.h := ((screenbits.bounds.Right - screenbits.bounds.Left) div 2) - (304 div 2);
- myEvent.where.v := ((screenbits.bounds.Bottom - screenbits.bounds.Top) div 3) - (104 div 2);
- InitCursor;
- chCode := DIBadMount(myEvent.where, myevent.message);
- END;
- END;
-
- ActivateEvt :
- BEGIN
- whichWindow := WindowPtr(myevent.message);
- IF odd(myEvent.modifiers) then
- BEGIN
- SelectWindow(whichWindow);
- END;
- END;
-
- otherwise;
- END;
- END;
- UNTIL doneFlag;
- END.
-